package com.hlb.ssm.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hlb.ssm.dao.StudentMapper;
import com.hlb.ssm.page.Page;
import com.hlb.ssm.pojo.Student;
import com.hlb.ssm.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

/**
 * Created by Administrator on 2016/12/18.
 */
@Service
public class StudentServiceImpl implements StudentService{
    @Autowired
    private StudentMapper studentMapper;
    public List<Student> findAll() {
        return this.studentMapper.findAll();
    }

    public Student getOne(Serializable id) {
        return this.studentMapper.getOne(id);
    }

    public void insert(Student student) {
        studentMapper.insert(student);
    }

    public void delete(Serializable id) {
        studentMapper.delete(id);
    }

    public void update(Student student) {
        studentMapper.update(student);
    }

    public Page<Student> getPage(int  pageNo,int pageSize){
        Page<Student> page=new Page<Student>();
        PageHelper.startPage(pageNo,page.getPageSize());
         List<Student> students=studentMapper.findAll();
        page.setList(students);
        PageInfo pageInfo=new PageInfo(students);
        page.setPageInfo(pageInfo);
        System.out.println(page);
        return page ;
    }
}
